package cn.legend.travel.tour.team.utils;

import cn.legend.travel.tour.team.pojo.entity.Tour;
import cn.legend.travel.tour.team.pojo.po.TourDetailPO;
import cn.legend.travel.tour.team.pojo.po.TourPO;
import cn.legend.travel.tour.team.pojo.vo.TourDetailVO;
import cn.legend.travel.tour.team.pojo.vo.TourVO;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class TourPOToTourVOConverter {

    public static TourVO convert(TourPO tourPO){
        TourVO tourVO = new TourVO();
        BeanUtils.copyProperties(tourPO,tourVO);
        String keywords = tourPO.getKeywords();
        String[] split = keywords.split(", ");
        List<String> list = new ArrayList<>(Arrays.asList(split));
        tourVO.setKeywords(list);

        return tourVO;
    }

    public static TourDetailVO DetailPO2DetailVOConvert(TourDetailPO tourDetailPO){
        TourDetailVO tourDetailVO = new TourDetailVO();
        BeanUtils.copyProperties(tourDetailPO,tourDetailVO);
        String keywords = tourDetailPO.getKeywords();
        String[] split = keywords.split(", ");
        List<String> list = new ArrayList<>(Arrays.asList(split));
        tourDetailVO.setKeywords(list);

        return tourDetailVO;
    }
}
